/* 通知组件样式 */

.notification {
  position: relative;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  max-width: 400px;
  min-width: 120px;
  min-height: 36px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: normal;
  word-wrap: break-word;
  overflow: visible;
  pointer-events: auto; /* 恢复通知本身的交互 */
  /* 高性能动画优化 */
  will-change: transform, opacity, max-height;
  transform: translateZ(0);
  /* 创建独立的合成层，避免影响其他元素 */
  isolation: isolate;
  /* 优化渲染性能 */
  contain: layout style paint;
}

.notification.success {
  background-color: var(--theme-primary-light);
  color: var(--theme-primary-dark);
  border: 1px solid var(--theme-primary);
}

.notification.error {
  background-color: var(--theme-primary-lighter);
  color: var(--theme-primary-dark);
  border: 1px solid var(--theme-primary);
}

.notification.warning {
  background-color: var(--theme-primary-lighter);
  color: var(--theme-primary-dark);
  border: 1px solid var(--theme-primary);
}

.notification.info {
  background-color: var(--theme-primary-lighter);
  color: var(--theme-primary-dark);
  border: 1px solid var(--theme-primary);
}

/* 暗色主题通知 */
[data-theme="dark"] .notification.success {
  background-color: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .notification.error {
  background-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .notification.warning {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .notification.info {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.3);
}

/* 通知动画 - 优化性能，减少抖动 */
@keyframes slideDown {
  from {
    transform: translateY(-20px) translateZ(0);
    opacity: 0;
  }
  to {
    transform: translateY(0) translateZ(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  0% {
    transform: translateY(0) translateZ(0) scale(1);
    opacity: 1;
    max-height: 100px;
    margin-bottom: 8px;
  }
  50% {
    transform: translateY(-10px) translateZ(0) scale(0.98);
    opacity: 0.7;
    max-height: 80px;
    margin-bottom: 6px;
  }
  100% {
    transform: translateY(-20px) translateZ(0) scale(0.95);
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
  }
}

.notification.slide-out {
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  overflow: hidden;
  /* 确保动画在独立层执行 */
  transform-origin: center top;
}

/* 通知图标 */
.notification-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
  font-size: 16px;
}

/* 通知关闭按钮 */
.notification-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.notification-close:hover {
  opacity: 1;
}

/* 通知堆叠 */
.notification-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  pointer-events: none; /* 防止影响页面交互 */
  will-change: transform; /* 优化动画性能 */
}

/* 响应式通知 */
@media (max-width: 768px) {
  .notification {
    top: 20px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 320px;
    min-width: 120px;
    min-height: 36px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.3;
  }

  .notification-container {
    top: 20px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: 340px;
  }
}
